let arr = [0, 1, 2, 3,4]
function find(arr, key) {
  let len = arr.length - 1
  let left = 0
  let right = len
  while (left < right) {
    var mid = Math.floor((right + left) / 2)
    if (key == arr[mid]) {
      return true
    }
    if (key > arr[mid]) {
      left = mid + 1
    } else {
      right = mid - 1
    }
  }
  return false
}
console.log(find(arr, 0))